package middleware

import (
	"editor/constant"
	"fmt"
	"github.com/gin-gonic/gin"
)

func StaticFSCache(c *gin.Context) {
	/*
		pathName := constant.StaticDir + c.Request.RequestURI
		_, err := os.Stat(pathName)
		if err != nil {
			c.Next()
			return
		}

		// 设置缓存控制头部信息
		cacheControlHeader := "private, max-age=86400"
		expiresHeader := time.Now().Add(time.Hour * 24).Format(time.RFC1123)
		etagHeader := fmt.Sprintf(`W/"%x"`, utils.GetFileMD5(pathName))

		c.Writer.Header().Set("Cache-Control", cacheControlHeader)
		c.Writer.Header().Set("Expires", expiresHeader)
		c.Writer.Header().Set("Etag", etagHeader)
	*/
	c.Next()
}

func MDFileCache(c *gin.Context) {
	pathName := constant.MDFileDir + c.Request.RequestURI

	fmt.Println("pathName", pathName)
	c.Next()
}
